Capping
glClipPlane( GL_CLIPPLANEi, (GLdouble *) equation );
where
equation
( point P, normal N ) = [ Nx, Ny, Nz, -(NxPx + NyPy + NzPz) ]
glEnable( GL_CLIPPLANEi );
glEnable( GL_DEPTH_TEST );
glEnable( GL_STENCIL_TEST );
glStencilFunc( GL_ALWAYS, ref = 0, mask = 1 );
glStencilOp( fail = GL_INVERT, zfail = GL_INVERT, zpass = GL_INVERT );
drawScene ( );
glDisable( GL_CLIPPLANEi );
glDisable( GL_DEPTH_TEST );
glStencilFunc( GL_EQUAL, ref = 1, mask = 1 );
glStencilOp( fail = GL_KEEP, zfail = GL_ZERO, zpass = GL_ZERO );
cappingPolygon = planeIntersect ( equation, scene.bbox );
drawPolygon ( cappingPolygon );